//
//  YCommentBodyView.m
//  yuimall_Iphone
//
//  Created by yuike6 yuike6 on 12-4-14.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import "YCommentBodyView.h"
#import "header.h"

@implementation YCommentBodyView
@synthesize commentData = commentData_;

@synthesize conentLabel = conentLabel_;
@synthesize createDateLabel = createDateLabel_;

-(void) dealloc
{
    YRelease(commentData_);
        
    YRelease(conentLabel_);
    YRelease(createDateLabel_);
    [super dealloc];
}


-(void) setCommentData:(YCommentModel *)commentDataValue
{
    YRelease(commentData_);
    commentData_ = [commentDataValue retain];
    
    if (!commentDataValue) 
    {
        return;
    }
    
    [self.conentLabel setText:commentDataValue.body.content];
    [self.createDateLabel setText:[NSDate date2string:commentDataValue.craeteDate]];
}
-(void) privateInit
{
    if (self.bInited) {
        return;
    }
    
    UILabel * tmp_label = [[UILabel alloc] init];
    [tmp_label setTextAlignment:UITextAlignmentLeft];
    [tmp_label setFont:[UIFont systemFontOfSize:14]];
    [tmp_label setTextColor:COLOR_BLACK];
    tmp_label.lineBreakMode = UILineBreakModeCharacterWrap;     
    tmp_label.numberOfLines = 0;
    self.conentLabel = tmp_label;
    YRelease(tmp_label);
    [self addSubview:self.conentLabel];
    
    UILabel * tmp_createlabel = [[UILabel alloc] init];
    [tmp_createlabel setTextAlignment:UITextAlignmentRight];
    [tmp_createlabel setFont:[UIFont systemFontOfSize:14]];
    [tmp_createlabel setTextColor:COLOR_GRAY];
    
    
    self.createDateLabel = tmp_createlabel;
    YRelease(tmp_createlabel);
    [self addSubview:self.createDateLabel];
    
    
    [self reAdjustLayout];
    self.bInited = TRUE;
}


-(id) init
{
    self = [super init];
    if (self) 
    {
        [self privateInit];
    }
    return self;
}


- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) 
    {
        // Initialization code
        [self privateInit];
    }
    return self;
}


-(void) reAdjustLayout
{
    [self.conentLabel setFrame:CGRectMake(2, 2, self.width - 4, self.height - 25)];
    
    [self.createDateLabel setFrame:CGRectMake(self.width - 150, self.height - 20, 135, 15)];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
